/**
 * 
 */
package com.jiang.action;

import javax.servlet.http.HttpSession;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.ServletActionContext;

import com.jiang.vo.User;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @author Administrator
 *
 */
@SuppressWarnings("serial")
public class LoginAction extends ActionSupport {

	private User user;

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * 登录方法
	 * @return
	 */
	public String login() {
		// 前面算是验证成功了, 随便用户名与密码了
		if (user!=null && StringUtils.isNotBlank(user.getUsername()) && StringUtils.isNotBlank(this.user.getPassword())) {
			HttpSession session = ServletActionContext.getRequest().getSession();
			session.setAttribute("user", user);
		}
		return SUCCESS;
	}

}
